<template>
    <div>
        <template>
            <div>
                <el-table :data="buildingNumberList" border stripe height="860" :summary-method="getSummaries" 
                    show-summary :header-cell-style="{ 'text-align': 'center' }"
                    :cell-style="{ 'text-align': 'center' }">
                    <el-table-column prop="" label="分摊成本合计明细表(未售)">
                        <template slot-scope="scope">
                            <el-table :data="scope.row.list" :show-header="scope.$index === 0"  :row-class-name="rowClassName" :header-cell-style="{'text-align':'center'}" :cell-style="{'text-align':'center'}">
                                <el-table-column fixed  prop="number" label="楼号">
                                </el-table-column>
                                <el-table-column prop="type_title" label="业态">
                                </el-table-column>
                                <el-table-column prop="d_1" label="土地使用权支付金额" :formatter="stateFormat">
                                </el-table-column>
                                <el-table-column prop="d_2" label="土地征用及拆迁补偿费" :formatter="stateFormat">
                                </el-table-column>
                                <el-table-column prop="d_3" label="前期工程费" :formatter="stateFormat">
                                </el-table-column>
                                <el-table-column prop="d_4" label="建筑安装工程费" :formatter="stateFormat">
                                </el-table-column>
                                <el-table-column prop="d_5" label="基础设施费" :formatter="stateFormat">
                                </el-table-column>
                                <el-table-column prop="d_6" label="配套设施费" :formatter="stateFormat">
                                </el-table-column>
                                <el-table-column prop="d_7" label="开发间接费" :formatter="stateFormat">
                                </el-table-column>
                                <!-- <el-table-column prop="b_8" label="单位成本" :formatter="stateFormat">
                                </el-table-column> -->
                                <el-table-column prop="d_sum_exclusive" label="合计" :formatter="stateFormat">
                                </el-table-column>


                            </el-table>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
        </template>
    </div>
</template>

<script>
import calculateApi from '@/api/calculate'

export default {
    data() {
        return {
            calculate_id: '',
            buildingNumberList: []
        }

    },
    methods: {
        getCalculateBuildingNumberList() {
            calculateApi.getCalculateBuildingNumberList(this.calculate_id).then(response => {
                this.buildingNumberList = response.data.list;
            })
        },
        rowClassName({ row, rowIndex }) {
            if (row.type === 6 || row.type === 10) {
                return 'warning-row';
            }
            if(row.d_sum_exclusive == 0){
                return 'warning-row';
            }
            return '';
        }
    },
    created() {
        var query = this.$route.query;
        if (query.id) {
            this.calculate_id = query.id;
        }

        this.getCalculateBuildingNumberList();
    },
}
</script>

<style>
.el-table .warning-row {
    display: none; 
}
</style>